#ifndef RESUME_TASK_H
#define RESUME_TASK_H

#include "task/sync_request_task.h"
#include <thread>

class ResumeTask: public task::SyncRequestTask
{
public:
    explicit ResumeTask(const std::string &name)
        : SyncRequestTask(name)
    {

    }
    ~ResumeTask() override
    {
        delete thread;
    }
    bool onStart() override
    {
        EASE_INFO("name: %s, start pass", task_name_.c_str());
        thread = new std::thread(&ResumeTask::sleepResume, this);
        thread->detach();
        return true;
    }

    void sleepResume()
    {
        int time = 10;
        sleep(time);
        EASE_INFO("name: %s, sleep %ds, resume", task_name_.c_str(), time);
        resume();
        EASE_INFO("name: %s, sleep %ds, resume done", task_name_.c_str(), time);
    }

private:
    std::thread *thread;
};

#endif //RESUME_TASK_H
